<?php

function checkSN($inSN,$pen = false){                                   		//WORKING
    settype($inSN,"integer");
    
    if($pen){
    	$sql = sprintf("SELECT name FROM pendingmembers WHERE SN = %s;",$inSN);
    }else{
    	$sql = sprintf("SELECT name FROM members WHERE SN = %s;",$inSN);
    }
    $res = sendQ($sql);
    $resA = mysql_fetch_array($res);
    $name = $resA['name'];
    
    //Checking if sn is member
    if($name != null){
        return $name;
    }
    return 0;
}


function isWLEmpty($event){
	settype($event,"integer");
	$sql = sprintf("SELECT COUNT(*) FROM event_%s_waitlist;",$event);
	$res = sendQ($sql);
	$count = mysql_fetch_array($res);
	$count = $count['COUNT(*)'];
	
	if($count == 0){
		return true;
	}
	
	return false;
}



function isEventFull($inEvent){                                                 //WORKING
	settype($inEvent,"integer");
        
	$sql = sprintf("SELECT max FROM events WHERE ID = %s;", $inEvent);
	$res = sendQ($sql);
	$resA = mysql_fetch_array($res);
	$max = 0;
	$cur = 0;
	
	if($resA == null){
		//WRONG ID
	}else{
		$max = $resA['max'];
	}
	
	$sql = sprintf("SELECT COUNT(*) FROM event_%s;", $inEvent);
	$res = sendQ($sql);
	$resA = mysql_fetch_array($res);
	$cur = $resA['COUNT(*)'];
	
	if((int)$cur == (int)$max){
		return true;
	}else{
		return false;
	}
}

?>